var t = require;
var e = module;
var o = exports;
var n;
Object.defineProperty(o, "__esModule", {value: !0}),
    (o.anis = o.EffectName = void 0),
    (function (t) {
        (t[(t["扫光"] = 0)] = "扫光"),
            (t[(t["太阳"] = 1)] = "太阳"),
            (t[(t["内发光"] = 2)] = "内发光"),
            (t[(t["扩散"] = 3)] = "扩散"),
            (t[(t["短呼吸"] = 4)] = "短呼吸"),
            (t[(t["长呼吸"] = 5)] = "长呼吸"),
            (t[(t["闪电"] = 6)] = "闪电"),
            (t[(t["进度"] = 7)] = "进度"),
            (t[(t.BUFF = 8)] = "BUFF"),
            (t[(t["走光"] = 9)] = "走光"),
            (t[(t["漂浮"] = 10)] = "漂浮"),
            (t[(t["漂浮影子"] = 11)] = "漂浮影子"),
            (t[(t["戳戳"] = 12)] = "戳戳");
    })((n = o.EffectName || (o.EffectName = {})));
var r,
    a = (function () {
        function t() {}
        return (
            (t.init = function (t) {
                this.effects = {};
                for (var e = 0, o = t; e < o.length; e++) {
                    var n = o[e];
                    this.effects[n.name] = n;
                }
                if (this.Effects未初始化就调用的货都放这里.length) {
                    for (var r = 0, a = this.Effects未初始化就调用的货都放这里; r < a.length; r++) {
                        var i = a[r];
                        this.add(i);
                    }
                    this.Effects未初始化就调用的货都放这里.length = 0;
                }
                if (((this.Effects未初始化就调用的货都放这里 = null), this.Effects未初始化就设置的货都放这里.length)) {
                    for (var s = 0, c = this.Effects未初始化就设置的货都放这里; s < c.length; s++) {
                        var l = c[s];
                        this.setProps(l);
                    }
                    this.Effects未初始化就设置的货都放这里.length = 0;
                }
                this.Effects未初始化就设置的货都放这里 = null;
            }),
            (t.add = function (t) {
                var e = this;
                if (("number" == typeof t.name && (t.name = n[t.name]), r[t.name])) r[t.name](t);
                else if (this.effects) {
                    if (this.effects[t.name]) {
                        var o = t.target || t.self;
                        this.lateCall(o, function () {
                            e._add(t);
                        });
                    } else console.error("木有Effect：" + t.name);
                } else this.Effects未初始化就调用的货都放这里.push(t);
            }),
            (t.clear = function (t) {
                t.stopAllActions();
            }),
            (t.setProps = function (t) {
                var e = this;
                this.effects
                    ? this.lateCall(t.node, function () {
                          e._setProps(t);
                      })
                    : this.Effects未初始化就设置的货都放这里.push(t);
            }),
            (t.lateCall = function (t, e) {
                if (t.activeInHierarchy) e();
                else {
                    var o = t.addComponent(cc.Component);
                    o.lateUpdate = function () {
                        o.destroy(), e();
                    };
                }
            }),
            (t._add = function (t) {
                var e = t.self.getComponent(cc.Sprite);
                if (e) {
                    var o = e.spriteFrame;
                    if (o) {
                        var n = o.getTexture();
                        if (n) {
                            var r = cc.Material.create(this.effects[t.name]),
                                a = o.getRect(),
                                i = o._capInsets || [0, 0, 0, 0],
                                s = new cc.Vec4(a.x / n.width, a.y / n.height, a.width / n.width, a.height / n.height),
                                c = new cc.Vec4(0, 0, t.self.width, t.self.height);
                            if (
                                (r.setProperty("selfXYWH", s),
                                r.setProperty("selfRect", c),
                                i && (i[0] > 0 || i[1] > 0 || i[2] > 0 || i[3] > 0))
                            ) {
                                var l = new cc.Vec4(
                                        i[0] / a.width,
                                        i[1] / a.height,
                                        1 - i[2] / a.width,
                                        1 - i[3] / a.height
                                    ),
                                    u = new cc.Vec4(
                                        i[0] / t.self.width,
                                        i[1] / t.self.height,
                                        1 - i[2] / t.self.width,
                                        1 - i[3] / t.self.height
                                    );
                                r.setProperty("spSlice", l), r.setProperty("selfSlice", u);
                            } else r.define("USE_SLICE", !1);
                            if (t.target) {
                                var p = t.target.getComponent(cc.Sprite);
                                if (!p) return void console.error("木有 targetSp：" + t.target.name);
                                var f = p.spriteFrame;
                                if (!f) return void console.error("木有 targetSF：" + t.target.name);
                                var d = f.getTexture();
                                if (!d) return void console.error("木有 targetTex：" + t.target.name);
                                var h = f.getRect(),
                                    y = new cc.Vec4(
                                        h.x / d.width,
                                        h.y / d.height,
                                        h.width / d.width,
                                        h.height / d.height
                                    ),
                                    g = new cc.Vec4(h.x, h.y, h.width, h.height);
                                r.setProperty("targetXYWH", y),
                                    r.setProperty("targetRect", g),
                                    r.setProperty("targetTex", d),
                                    r.define("USE_TARGET", !0);
                            } else r.define("USE_TARGET", !1);
                            r.setProperty("ran", t.ran ? Math.random() : 0),
                                r.define("SHOW_TARGET", t.showTarget),
                                e.setMaterial(0, r);
                        } else console.error("木有 selfTex：" + t.self.name);
                    } else console.error("木有 selfSF：" + t.self.name);
                } else console.error("木有 selfSp：" + t.self.name);
            }),
            (t._setProps = function (t) {
                var e = t.node.getComponent(cc.Sprite);
                if (e) {
                    var o = e.getMaterial(0);
                    if (t.props) for (var n in t.props) o.setProperty(n, t.props[n]);
                    if (t.defines) for (var n in t.defines) o.define(n, t.defines[n]);
                    e.setMaterial(0, o);
                } else console.error("木有 selfSp：" + t.node.name);
            }),
            (t.Effects未初始化就调用的货都放这里 = []),
            (t.Effects未初始化就设置的货都放这里 = []),
            t
        );
    })();
(o.default = a),
    (function (t) {
        (t.扩散 = function (t) {
            (t.self.opacity = 0),
                (t.self.scaleX = t.self.scaleY = 1),
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 1 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.fadeTo(0.2, 255),
                                        cc.delayTime(0.6),
                                        cc.fadeTo(0.2, 0),
                                        cc.delayTime(1)
                                    )
                                )
                            ),
                                t.self.runAction(
                                    cc.repeatForever(
                                        cc.sequence(
                                            cc.scaleTo(1, 1.6).easing(cc.easeCubicActionInOut()),
                                            cc.delayTime(1),
                                            cc.callFunc(function () {
                                                t.self.scaleX = t.self.scaleY = 1;
                                            })
                                        )
                                    )
                                );
                        })
                    )
                );
        }),
            (t.短呼吸 = function (t) {
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 1 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.scaleTo(0.3, 1.1, 1.1).easing(cc.easeSineInOut()),
                                        cc.scaleTo(0.2, 0.9, 0.9).easing(cc.easeSineInOut()),
                                        cc.scaleTo(0.3, 1.1, 1.1).easing(cc.easeSineInOut()),
                                        cc.scaleTo(0.2, 1, 1).easing(cc.easeSineInOut()),
                                        cc.delayTime(1)
                                    )
                                )
                            );
                        })
                    )
                );
            }),
            (t.长呼吸 = function (t) {
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 3 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.scaleTo(1, 1.2, 1.2).easing(cc.easeSineInOut()),
                                        cc.scaleTo(1, 0.8, 0.8).easing(cc.easeSineInOut()),
                                        cc.scaleTo(1, 1.2, 1.2).easing(cc.easeSineInOut()),
                                        cc.scaleTo(1, 1, 1).easing(cc.easeSineInOut()),
                                        cc.delayTime(3)
                                    )
                                )
                            );
                        })
                    )
                );
            }),
            (t.漂浮 = function (t) {
                var e = t.self.y,
                    o = e + 0.1 * t.self.height;
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 2 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.moveTo(1, t.self.x, o).easing(cc.easeSineInOut()),
                                        cc.moveTo(1, t.self.x, e).easing(cc.easeSineInOut())
                                    )
                                )
                            );
                        })
                    )
                );
            }),
            (t.漂浮影子 = function (t) {
                var e = t.self.opacity,
                    o = 0.6 * e;
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 2 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.fadeTo(1, o).easing(cc.easeSineInOut()),
                                        cc.fadeTo(1, e).easing(cc.easeSineInOut())
                                    )
                                )
                            );
                        })
                    )
                );
            }),
            (t.戳戳 = function (t) {
                var e = t.self.x,
                    o = e + 0.1 * t.self.width;
                t.self.runAction(
                    cc.sequence(
                        cc.delayTime(t.ran ? 2 * Math.random() : 0),
                        cc.callFunc(function () {
                            t.self.runAction(
                                cc.repeatForever(
                                    cc.sequence(
                                        cc.moveTo(1, o, t.self.y).easing(cc.easeSineInOut()),
                                        cc.moveTo(1, e, t.self.y).easing(cc.easeSineInOut())
                                    )
                                )
                            );
                        })
                    )
                );
            });
    })((r = o.anis || (o.anis = {})));
